/*
 * ledMatrix.c
 *  Arizona State University
 *  CSE 325: Embedded Systems Programming
 *  Lab 7: Morse Code
 *  Georgii Tkachuk, Brentton Garber
 *   Emails: 	gtkachuk@asu.edu btgarber@asu.edu
 *      
 */
#include "common.h"

// Define our global row count and color bytes
uint8 G_ROW = 0;
uint8 G_RED[8];
uint8 G_GREEN[8];

// Initialize our led matrix components
void ledmatrix_init()
{
	// Configure port QS pins 0 - 2 for the primary (QSPI) function.
	MCF_GPIO_PTHPAR &= ~(15 << 12);
	
	// Configure port TH pins 6 - 7 for the quaternary (GPIO) function
	MCF_GPIO_DDRTH |= (3 << 6);
	
	// Initialize the QSPI module to transmit bits at a maximum clock frequency of 5MHz
	qspi_init();
	
}

// Refresh the led matrix
void ledmatrix_refresh()
{
	// Write the current row to the led matrix
	ledmatrix_write_row();
	
	// Increase our current row count
	G_ROW = (G_ROW + 1) % 8;
}

// Transmit a row data packet
void ledmatrix_write_row()
{
	// Make our data packet
	uint8 data[3];
	data[0] = G_RED[G_ROW];
	data[1] = G_GREEN[G_ROW];
	data[2] = (unsigned char)~(1 << G_ROW);
	
	MCF_GPIO_PORTTH &= ~MCF_GPIO_PORTTH_PORTTH6;
	MCF_GPIO_PORTTH |= MCF_GPIO_PORTTH_PORTTH7; 
	
	// Transfer our data packet
	qspi_transfer(data);
	
	// Flush the data to the ram
	MCF_GPIO_PORTTH |= MCF_GPIO_PORTTH_PORTTH6;
	MCF_GPIO_PORTTH &= ~MCF_GPIO_PORTTH_PORTTH7; 
}

// Transfer our pattern array into red and green bytes
void ledmatrix_write(uint8 pattern[8][8])
{
	int row, col;
	
	// Loop through each of the rows
	for(row=0; row<8;row++)
	{
		// Set our green and red bytes to 0
		G_GREEN[row] = 0x0000;
		G_RED[row] = 0x0000;
		
		// Loop through each of the columns
		for(col=0;col<8;col++)
		{
			// If the color of the dot is Red, set our bit in the Red Byte
			if(pattern[7-col][7-row] == RED)
				G_RED[row] |= 1 << col;
			
			// If the color of the dot is Green, set our bit in the Green Byte
			if(pattern[7-col][7-row] == GREEN)
				G_GREEN[row] |= 1 << col;
			
			// If the color of the dot is Red, set our bit in both the Red and Green Bytes
			if(pattern[7-col][7-row] == ORANGE) {
				G_RED[row] |= 1 << col;
				G_GREEN[row] |= 1 << col;
			}
		}
	}
}

// writes a character to the led matrix
void ledmatrix_writeChar(int letter)
{
	uint8 letters[][8][8] = 
	{
		{ // A
			{ BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, GREEN, GREEN, GREEN, GREEN, GREEN, BLACK, BLACK },
			{ GREEN, BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // B
			{ BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // C
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK },
		},
		{ // D
			{ BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK },
		},
		{ // E
			{ BLACK, BLACK, GREEN, GREEN, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // F
			{ BLACK, BLACK, GREEN, GREEN, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // G
			{ BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, GREEN, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK },
		},
		{ // H
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, GREEN, GREEN, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // I
			{ BLACK, BLACK, GREEN, GREEN, GREEN, GREEN, GREEN, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, GREEN, GREEN, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // J
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, GREEN, GREEN, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, GREEN, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // K
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
		},
		{ // L
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, GREEN, GREEN, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // M
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK, GREEN },
			{ BLACK, GREEN, GREEN, BLACK, BLACK, BLACK, GREEN, GREEN },
			{ BLACK, GREEN, BLACK, GREEN, BLACK, GREEN, BLACK, GREEN },
			{ BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK, GREEN },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK, GREEN },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK, GREEN },
		},
		{ // N
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, GREEN, GREEN, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, GREEN, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, GREEN, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, GREEN, GREEN, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // O
			{ BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // P
			{ BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // Q
			{ BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, GREEN },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // R
			{ BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // S
			{ BLACK, BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // T
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, GREEN, GREEN, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // U
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // V
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK, GREEN },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // W
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ GREEN, BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, GREEN, BLACK, GREEN, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // X
			{ GREEN, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, GREEN },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ GREEN, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, GREEN },
		},
		{ // Y
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK, GREEN },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
		},
		{ // Z
			{ GREEN, GREEN, GREEN, GREEN, GREEN, GREEN, GREEN, GREEN },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ GREEN, GREEN, GREEN, GREEN, GREEN, GREEN, GREEN, GREEN },
		},
		{ // 1
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, GREEN, GREEN, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // 2
			{ BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // 3
			{ BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK },
		},
		{ // 4
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
		},
		{ // 5
			{ BLACK, BLACK, GREEN, GREEN, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK, BLACK },
		},
		{ // 6
			{ BLACK, BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK },
		},
		{ // 7
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, GREEN, GREEN, GREEN, GREEN, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // 8
			{ BLACK, BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK },
		},
		{ // 9
			{ BLACK, BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, GREEN, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK, BLACK },
		},
		{ // 0
			{ BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, GREEN, BLACK, BLACK, BLACK, BLACK, GREEN, BLACK },
			{ BLACK, BLACK, GREEN, BLACK, BLACK, GREEN, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, GREEN, GREEN, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // NO SEQUENCE # 37
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, RED  , BLACK, BLACK, BLACK, RED  , BLACK },
			{ BLACK, BLACK, BLACK, RED  , BLACK, RED  , BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, RED  , BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, RED  , BLACK, RED  , BLACK, BLACK },
			{ BLACK, BLACK, RED  , BLACK, BLACK, BLACK, RED  , BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
		},
		{ // BLANK
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK },
			{ BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK }
		}
	};
	
	// write the letter to the led matrix
	ledmatrix_write(letters[(uint8)letter]);

}
